#include <iostream>
#include <vector>
#include <string>

using namespace std;

int reverse(int x) {
    long n = 0;
	while (x){
		n = n * 10 + x % 10;
		x /= 10;
	}
	return n > INT_MAX || n < INT_MIN ? 0 : n;
}

int main(){
    int x = -123;
    cout << reverse(x) << endl;
    return 0;
}
